package com.fr.chart.core;

import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.base.equals.Equals;
import com.fr.report.io.xml.ReportXMLUtils;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;

public abstract class RectangleGlyph extends GeneralGlyph
{
  private static final long serialVersionUID = -3506981313101696057L;
  protected boolean visible;
  public static RectangularShape NULL_SHAPE = new Rectangle()
  {
    public Rectangle2D getBounds2D()
    {
      return this;
    }
  };
  protected transient RectangularShape bounds = NULL_SHAPE;

  public void setBounds(RectangularShape paramRectangularShape)
  {
    this.bounds = paramRectangularShape;
  }

  public Rectangle2D getBounds()
  {
    if (this.bounds != null)
      return this.bounds.getBounds2D();
    return null;
  }

  public void setVisible(boolean paramBoolean)
  {
    this.visible = paramBoolean;
  }

  public boolean isVisible()
  {
    return this.visible;
  }

  public Shape getOutline4Fill()
  {
    return this.bounds;
  }

  public Shape getShape()
  {
    return this.bounds;
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof RectangleGlyph))
      return false;
    RectangleGlyph localRectangleGlyph = (RectangleGlyph)paramObject;
    if (!(super.equals(localRectangleGlyph)))
      return false;
    if (!(Equals.equals(localRectangleGlyph.getBounds(), getBounds())))
      return false;
    return (localRectangleGlyph.isVisible() == isVisible());
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str1 = paramXMLableReader.getTagName();
      if ("Bounds".equals(str1))
        this.bounds = ReportXMLUtils.readRectangularShape(paramXMLableReader);
      if (str1.equals("Visible"))
      {
        String str2;
        if ((str2 = paramXMLableReader.getAttr("value")) != null)
          this.visible = Boolean.valueOf(str2).booleanValue();
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    if (this.bounds != null)
      ReportXMLUtils.writeRectangularShape(paramXMLPrintWriter, this.bounds);
    paramXMLPrintWriter.startTAG("Visible").attr("value", this.visible).end();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    RectangleGlyph localRectangleGlyph = (RectangleGlyph)super.clone();
    if (this.bounds != null)
      localRectangleGlyph.bounds = ((RectangularShape)this.bounds.clone());
    return localRectangleGlyph;
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    JSONObject localJSONObject = super.toJSONObject();
    localJSONObject.put("visible", this.visible);
    return localJSONObject;
  }
}